package com.xingshentech.ugv.operate.module.bean2;

import java.io.Serializable;

public class BaseResponseCenter<T> implements Serializable {
// 在 Android应用中进行 序列化（Serializable），
// 比如在 Intent 传递数据、缓存对象、网络传输等场景，那么它应该实现 Serializable 接口
    public final static int SUCCESS = 200;
    public final static int TOKEN_INVALID = 508;

    private int responseCode;
    private T result;
    private T data;
    private boolean status;
    private Error error;

    public Error getError() {
        return error;
    }

    public void setError(Error error) {
        this.error = error;
    }
//UI 组件通常只能读取，不能随便修改 ，所以用setter getter 方法
    /**
     * TOKEN是否过期
     *
     * @return true 过期 flase 未过期
     */
    public boolean isTokenValid() {
        return TOKEN_INVALID == responseCode;
    }

    public boolean isResponseCode() {
        return SUCCESS == responseCode;
    }

    public int getResponseCode() {
        return responseCode;
    }

    public void setResponseCode(int responseCode) {
        this.responseCode = responseCode;
    }

    public T getResult() {
        return result;
    }

    public void setResult(T result) {
        this.result = result;
    }

    public boolean isStatus() {
        return status;
    }

    public void setStatus(boolean status) {
        this.status = status;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public class Error implements Serializable {
        private String errorMessage;
        private String errorInternalMessage;
        private String errorCode;

        public String getErrorMessage() {
            return errorMessage;
        }

        public void setErrorMessage(String errorMessage) {
            this.errorMessage = errorMessage;
        }

        public String getErrorCode() {
            return errorCode;
        }

        public void setErrorCode(String errorCode) {
            this.errorCode = errorCode;
        }

        public String getErrorInternalMessage() {
            return errorInternalMessage;
        }

        public void setErrorInternalMessage(String errorInternalMessage) {
            this.errorInternalMessage = errorInternalMessage;
        }
    }
}
